// h1+d*t1>h2+d*t2
//h1-h2>d*(t2-t1)
//t2-t1==0   h1>h2
//t2-t1>0    d<h1-h2/t2-t1
//t2-t1<0    d>h1-h2/t2-t1
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int N=2*1e5+10;

int h[N],a[N],rk[N];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;

		cin>>n;
		for(int i=0;i<n;i++)
			scanf("%d",&h[i]);
		for(int i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(int i=0;i<n;i++)
		{
			int t;
			scanf("%d",&t);
			rk[t+1]=i;
		}
		bool flg=true;
		int minn=0,maxn=1e9;
		for(int i=1;i<n;i++)
		{
			int p1=h[rk[i]]-h[rk[i+1]];
			int p2=a[rk[i+1]]-a[rk[i]];
			if(p2>0)
			{
				maxn=min(maxn,(int)ceil(1.0*p1/p2)-1);
			}
			else if(p2<0){
				minn=max(minn,(int)floor(1.0*p1/p2)+1);
			}
			else if(p1<=0)
			{
				maxn=-1;
				break;
			}
		}
		if(!flg || minn>maxn)
		{
//			cout<<maxn<<' '<<minn<<endl;
			cout<<-1<<endl;
		}
		else{
			cout<<minn<<endl;
		}
	}
	return 0;
}
